package pages;

import core.TestBase;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import utils.Log4Test;

/**
 * Created by 1 on 13.07.2014.
 */
public class ApplePage extends TestBase {
    protected By searchTitle = By.tagName("h1");
    protected By clickField = By.xpath(".//*[@id='sort_view']/a/i");
    protected By searchOption = By.xpath(".//*[@id='sort_view']/div/div/ul/li[2]/a");
    protected By searchMac1 = By.xpath(".//*[@class='gtile-i-title']/a[@href='http://rozetka.com.ua/apple_macbook_pro_retina_15_z0pu002je/p699984/']");
    protected By searchMac2 = By.xpath(".//*[@class='gtile-i-title']/a[@href='http://rozetka.com.ua/apple_macbook_pro_retina_15_me294ua_a/p338650/']");
    protected By compareCheckBoxField1 = By.xpath(".//div[1]/div[1]/div/div/div[4]/div[1]/label/input");
    protected By compareCheckBoxField2 = By.xpath(".//div[3]/div[1]/div/div/div[4]/div[1]/label/input");
    protected By rightCornerBlock = By.xpath(".//*[@class='block']/ul/li/a[@href='http://rozetka.com.ua/apple_macbook_pro_retina_15_z0pu002je/p699984/']");
    protected By rightCornerBlock2 = By.xpath("//*[@class='block']/ul/li/a[@href='http://rozetka.com.ua/apple_macbook_pro_retina_15_me294ua_a/p338650/']");
    protected By inComparisonLink = By.xpath(".//*[@id='block_with_goods']/div[1]/div[1]/div[1]/div[1]/div/div/div[4]/div[1]/span/a");
    protected WebElement searchElem;

    public String verifyPageName() {

        Log4Test.info("Verify page name");

        searchElem = webDriver.findElement(searchTitle);

        return searchElem.getText();
    }

    public  void searchOptionClick(){
        WebElement w1 = webDriver.findElement(clickField);
        w1.click();
        WebElement w2 = webDriver.findElement(searchOption);
        w2.click();
    }

    public String verifyMac1(){
        WebElement w3 = webDriver.findElement(searchMac1);

        return w3.getText();
    }

    public void compareOptionClick(){
        WebElement w =webDriver.findElement(compareCheckBoxField1);
        w.click();


    }

    public String verifyRightCornerBlock(){
        WebElement w = webDriver.findElement(rightCornerBlock);

        return w.getText();
            }

    public String verifyMac2(){
        WebElement w = webDriver.findElement(searchMac2);

        return w.getText();
    }

    public void compareOptionClick2(){
        WebElement w =webDriver.findElement(compareCheckBoxField2);
        w.click();


    }

    public String verifyRightCornerBlock2(){
        WebElement w = webDriver.findElement(rightCornerBlock2);

        return w.getText();
    }

    public void inComparisonClick(){
        WebElement w =webDriver.findElement(inComparisonLink);
        w.click();


    }
}
